#ifndef _XX_YY_BMOCK_FIXTURE
#define _XX_YY_BMOCK_FIXTURE
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/stringize.hpp>
#include "detail/bmock_test_control_tools.hpp"
#include <iostream>
#include <vector>
#include <string>
#include <boost/algorithm/string.hpp>

#define __BMOCK_TEST(F, test_name)																						\
struct test_name : public F {																							\
	void test_method();																									\
};																														\
																														\
static void BOOST_AUTO_TC_INVOKER( test_name )()																		\
{																														\
	std::vector<std::string> strs;																						\
	boost::split(strs, BOOST_PP_STRINGIZE(test_name), boost::is_any_of("$"));											\
	std::string str = "Test Name: (" + strs[0] + ", " + strs[1] + ")";													\
	bmock::bmock_mutex::instance()->lock();																				\
	bmock::bmock_logfile::instance()->add_to_log("\n\n" + str);															\
	bmock::bmock_logfile::instance()->add_to_log(std::string(150, '='));												\
	bmock::bmock_logfile::instance()->add_to_log("Expectations:");														\
	bmock::bmock_mutex::instance()->unlock();																			\
																														\
	const bmock::control_tools_ptr p(new bmock::test_control_tools());													\
	bmock::test_mode_control c(bmock::location(__FILE__,__LINE__),p);													\
    test_name t;																										\
    t.test_method();																									\
}																														\
																														\
struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {};																			\
																														\
BOOST_AUTO_TU_REGISTRAR( test_name )(																					\
    boost::unit_test::make_test_case(																					\
        &BOOST_AUTO_TC_INVOKER( test_name ), #test_name ),																\
    boost::unit_test::ut_detail::auto_tc_exp_fail<																		\
        BOOST_AUTO_TC_UNIQUE_ID( test_name )>::instance()->value() );													\
																														\
void test_name::test_method()																							\

#define BMOCK_TEST(F, test_name)																						\
	__BMOCK_TEST(F, F##$##test_name)								

#endif